<template>
  <b-card
    title-tag="p"
    no-body
    :class="{ hover: hover }"
    @mouseover="hover = true"
    @mouseleave="hover = false"
  >
    <div class="b-card-img-wrapper">
      <div class="b-card-img-placeholder">
        <p style="font-size: 100px;">
          <font-awesome-icon icon="image" />
        </p>
        <span v-if="imgAlt">{{ imgAlt }}</span>
      </div>
      <b-card-img :src="imgSrc" top></b-card-img>
    </div>
    <b-card-body>
      <b-card-title>{{ name }}</b-card-title>
      <b-card-sub-title>{{ title }}</b-card-sub-title>
      <b-card-text>{{ desc }}</b-card-text>
      <b-button squared variant="outline-secondary" size="sm">
        了解详情
      </b-button>
    </b-card-body>
  </b-card>
</template>

<script>
export default {
  props: {
    name: {
      type: String,
      required: true,
    },
    title: {
      type: String,
      required: true,
    },
    desc: {
      type: String,
      required: true,
    },
    imgSrc: {
      type: String,
      required: true,
    },
    imgAlt: {
      type: String,
      default: null,
    },
  },
  data() {
    return {
      hover: false,
    };
  },
};
</script>

<style scoped>
.card {
  margin-top: 20px;
  border-radius: 0px;
}
.card.hover {
  margin-top: 20px;
  border-radius: 0px;
  box-shadow: 0px 0px 10px rgba(153, 153, 153, 0.349019607843137);
}
.card-body {
  height: 230px;
  padding: 1rem;
}
.card-title {
  font-size: 16px;
  font-weight: 400;
  color: #666;
  line-height: normal;
  display: inline-block;
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: #999;
  line-height: normal;
  display: inline-block;
  margin-bottom: 12px;
  /* overflow: hidden; */
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-text {
  font-size: 12px;
  font-weight: 400;
  color: #999;
  line-height: 24px;
  height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  margin-bottom: 6px;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.card-footer {
  height: 60px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0);
  padding-top: 0;
  padding-bottom: 0;
}
.card .card-body button {
  width: 90px;
  height: 35px;
  font-weight: 400 !important;
  font-style: normal;
  font-size: 12px;
  color: #999999;
  line-height: 24px;
  border-color: rgba(228, 228, 228, 1);
  transition: 0s;
  position: absolute;
  left: 12px;
  bottom: 12px;
}
.card.hover .card-body button {
  background-color: rgba(0, 121, 254, 1);
  border: none;
  border-radius: 45px !important;
  color: #fff;
}
.b-card-img-wrapper {
  width: 100%;
  height: 202px;
  position: relative;
  overflow: hidden;
}
.b-card-img-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  font-weight: 400;
  font-style: normal;
  font-size: 12px;
  color: #fff;
  line-height: 24px;
  text-align: center;
  background-color: rgba(228, 228, 228, 1);
}
.b-card-img-wrapper img {
  width: 100%;
  height: 202px;
  position: absolute;
  top: 0;
  left: 0;
}
</style>
